package com.paziy.jan.calc.literals.functions;


import com.paziy.jan.calc.literals.numbers.Num;
import com.paziy.jan.calc.literals.operations.exeptions.WrongCountOfOperands;

import java.util.LinkedList;

public class Sin extends Function {

    private static final String PATTERN = "[Ss][Ii][Nn]";

    private static final byte COUNT_OF_OPERANDS = (byte)1;

    private static final byte PRIORITY = Byte.MAX_VALUE;

    public Sin() {
        super(PATTERN, COUNT_OF_OPERANDS, PRIORITY);
    }

    @Override
    protected Num calculating(LinkedList<Num> stack) throws WrongCountOfOperands {
        return new Num(Math.sin(stack.pop().doubleValue()));
    }
}
